#include "dialog.ch"

//----------------------------------------------------------------------------//

CLASS Label FROM Visual

   DATA   cText
   DATA   cClrHotKey

   METHOD New        // LblNew
   METHOD Display    // LblDisplay
   METHOD SetFocus   // LblSetFocus
   METHOD cGetHotKey // cLblGetHotKey

ENDCLASS

//----------------------------------------------------------------------------//

METHOD New( nRow, nCol, cText )

   DEFAULT cText = "&Label"

   ::Parent:New()

   ::nTop       = nRow
   ::nLeft      = nCol
   ::nBottom    = nRow
   ::nRight     = nCol + nLabelLen( cText ) - 1
   ::cText      = cText
   ::cClrHotKey = "GR+" + SubStr( ::cClrNormal, At( "/", ::cClrNormal ) )   

return Self

//----------------------------------------------------------------------------//

METHOD Display()

   local nMCrsOld := SetMCursor()

   SetMCursor( 0 )
   SayHot( ::nAbsTop(), ::nAbsLeft(), ::cText,;
           If( ::lFocused, ::cClrFocus, ::cClrNormal ),;
           ::cClrHotKey )
   SetMCursor( nMCrsOld )

return nil

//----------------------------------------------------------------------------//

METHOD SetFocus( lOnOff, cClrFocus )

   ::Parent:SetFocus( lOnOff, cClrFocus )
   ::Display()

return nil

//----------------------------------------------------------------------------//

METHOD cGetHotKey()

   local nAt := At( "&", ::cText )

return If( nAt != 0, SubStr( ::cText, nAt + 1, 1 ), "" )

//----------------------------------------------------------------------------//